import { AllHTMLAttributes, createElement, type FC } from 'react';
import classNames from 'classnames';

import { listContentDefaultProps } from './defaultProps';
import type { ListContentOptions } from './type';

export interface ListContentProps extends ListContentOptions, Omit<AllHTMLAttributes<HTMLElement>, 'as'> {}

const ListContent: FC<ListContentProps> = (props) => {
  const { className, as, aligned, floated, children, forwardedRef, ...listContentProps } = props;

  return createElement(
    as!,
    {
      ref: forwardedRef,
      className: classNames(aligned, { aligned }, floated, { floated }, 'content', className),
      ...listContentProps,
    },
    children,
  );
};

ListContent.displayName = 'ListContent';
ListContent.defaultProps = listContentDefaultProps;

export default ListContent;
